import { Body, Controller, Post, Put, UseGuards } from '@nestjs/common';
import { AuthService } from './auth.service';
import { LoginAuthDto } from './dto/login-auth.dto';
import { CreateAuthDto } from './dto/create-auth.dto';
import { UpdateAuthDto } from './dto/update-auth.dto';
import { GetUserInfo } from 'src/dec/cu-dec/cu-dec.decorator';
import { AuthGuard } from 'src/gurad/auth/auth.guard';

@Controller('auth')
export class AuthController {
  constructor(private readonly authService: AuthService) {}

  @Post('login')
  login(@Body() loginAuthDto: LoginAuthDto) {
    return this.authService.login(loginAuthDto);
  }

  @Post('register')
  register(@Body() createAuthDto: CreateAuthDto) {
    return this.authService.register(createAuthDto);
  }

  @Put()
  @UseGuards(AuthGuard)
  reset(@Body() updateAuthDto: UpdateAuthDto, @GetUserInfo('id') id: number) {
    return this.authService.update(updateAuthDto, +id);
  }
}
